Python: Document shared chat client concurrency - #7680
Open
Ricky-7-Yan wants to merge 3 commits into
Open
Conversation
Ricky-7-Yan
had a problem deploying
to
github-app-auth
August 15, 2026 15:39 — with
GitHub Actions
Error
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR clarifies and validates the concurrency contract for the OpenAI and Foundry chat clients, documenting when a single client instance can be safely reused across concurrent async runs and adding a regression test to ensure concurrent runs remain isolated.
Changes:
- Documented concurrency/reuse guarantees (and non-guarantees) for
OpenAIChatClientandFoundryChatClientin docstrings and READMEs. - Added guidance to the core chat protocol docs that protocol conformance doesn’t imply concurrency safety.
- Added an async concurrency isolation test covering streaming, non-streaming, and mixed scenarios for both providers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/openai/agent_framework_openai/_chat_client.py | Adds explicit concurrency contract to OpenAIChatClient docstring. |
| python/packages/openai/README.md | Documents concurrent reuse guidance for OpenAI package users. |
| python/packages/foundry/agent_framework_foundry/_chat_client.py | Adds explicit concurrency contract to FoundryChatClient docstring. |
| python/packages/foundry/README.md | Documents concurrent reuse guidance for Foundry package users. |
| python/packages/core/agent_framework/_clients.py | Clarifies that protocol implementation doesn’t guarantee concurrency safety. |
| python/packages/foundry/tests/foundry/test_chat_client_concurrency.py | Adds regression test ensuring concurrent runs don’t leak state across requests/sessions. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Ricky-7-Yan
marked this pull request as ready for review
August 18, 2026 14:56
Ricky-7-Yan
requested review from
Tao Chen (TaoChenOSU),
chetantoshniwal,
Eduard van Valkenburg (eavanvalkenburg) and
Giles Odigwe (giles17)
as code owners
August 18, 2026 14:56
Ricky-7-Yan
had a problem deploying
to
github-app-auth
August 18, 2026 14:56 — with
GitHub Actions
Error
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
Long-lived async hosts need to reuse provider clients and their HTTP connection pools without leaking request-scoped Agent or session state. The Python API did not define whether
OpenAIChatClientandFoundryChatClientsupport concurrent reuse, especially when streaming and non-streaming calls overlap.Description & Review Guide
Agent,AgentSession, message set, and options request-scoped. There is no runtime or public API behavior change.Related Issue
Fixes #7654
Contribution Checklist
breaking changelabel (or add [BREAKING] to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.